﻿using System;
using System.IO;
using System.Windows;
using System.Windows.Media;
using System.Windows.Media.Imaging;

namespace Oxage.Common
{
	public class ResourceHelper
	{
		public static ImageSource GetImage(string relativePath)
		{
			//TODO: Get "cnc-studio" from assembly name
			var uri = new Uri(@"pack://application:,,,/cnc-studio;component/" + relativePath, UriKind.RelativeOrAbsolute);
			return BitmapFrame.Create(uri);
		}

		public static string GetString(string relativePath)
		{
			var uri = new Uri(@"pack://application:,,,/cnc-studio;component/" + relativePath, UriKind.RelativeOrAbsolute);
			var info = Application.GetResourceStream(uri);
			using (var stream = info.Stream)
			{
				using (var reader = new StreamReader(stream))
				{
					string result = reader.ReadToEnd();
					return result;
				}
			}
		}
	}
}
